home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.direct.ca!usenet
- From: etoivane@direct.ca (Ed Toivanen)
- Newsgroups: comp.lang.c
- Subject: Re: How to check array lenght?
- Date: 25 Feb 1996 21:50:45 GMT
- Organization: Your Organization
- Message-ID: <4gqljl$jno@aphex.direct.ca>
- References: <4gbphl$ht@malakor.kku.ac.th> <Pine.A32.3.91.960221002504.156335H-100000@black.weeg.uiowa.edu> <4ggmfs$tg@dopey.magg.net>
- NNTP-Posting-Host: 204.174.243.150
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.6
-
- In article <4ggmfs$tg@dopey.magg.net>, n4mwd@magg.net says...
-
- >Try using:
- >
- >#define numelem(array) (sizeof(array) / sizeof(array[0]))
- >
- >then pass the results as an extra parameter to your function.
-
- sizeof(array) is the pointer size, not the size of the array in bytes, and
- sizeof(array[0]) is the size of the 0th element. Not exactly what you
- intended. You have to keep track of the array size, then pass it as a
- parameter.
-
- Ed
-
-
-